<?php

    header('Content-Type:image/png');

    $im = imagecreatetruecolor(80,25);

    $bgc = imagecolorallocate($im,250,250,250);
    imagefilledrectangle($im,0,0,100,50,$bgc);

    for ($i=0; $i < 300; $i++) {

            $poc = imagecolorallocate($im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
            imagesetpixel($im,mt_rand(0,100),mt_rand(0,50),$poc);
    }
    for ($i=0; $i < 20; $i++) {

        $poc = imagecolorallocate($im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
        imagearc($im,mt_rand(20,80),mt_rand(10,100),mt_rand(50,100),mt_rand(25,150),mt_rand(0,50),mt_rand(-180,180),$poc);
    }

    $code = '';

    for ($i=0; $i < 5; $i++) {

        $poc = imagecolorallocate($im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
        $x = 15*$i+5;
        $num = mt_rand(0,9);
        imagefttext($im,20,mt_rand(-15,30),$x,mt_rand(18,25),$poc,'C:/Windows/Fonts/BrushScriptStd.otf',$num);
        $code .= $num;
    }

    $_SESSION['code'] = $code;

    ob_clean();

    imagepng($im);

    die;

?>
